﻿@model pgnSoft.Veloz.ERP.Models.PageModel

<!DOCTYPE html>

<html>
<head>

    @* Setando o título da página *@
    @if (@Model != null &&  !String.IsNullOrWhiteSpace(@Model.PageTitle))
    { 
        <title>@Model.PageTitle</title>    
    }
    else
    {
        <title>Sem título</title>    
    }

    @*<link rel="stylesheet" href="@Url.Content("~/Content/bootstrap.css")" />
    <script src="@Url.Content("~/Scripts/jquery-1.9.1.js")"></script>
    <script src="@Url.Content("~/Scripts/bootstrap.js")"></script>*@

    @* carregando os estilos, principais e exclusivos *@
    @if (@Model != null && !String.IsNullOrWhiteSpace(@Model.Style.FileName)) 
    {
        @Model.Style.Render(@Model.Style.FileName);
    }
    else
    {
        @Model.Style.Render("~/resources/css/default.css" );
    }

    @if (@Model.Style.Styles != null)
    {
        foreach (var style in @Model.Style.Styles)
        {
           @Model.Style.Render(style.FileName);
        }
    }


    @* carregando os scripts, principais e exclusivos *@
    @if (@Model != null && !String.IsNullOrWhiteSpace(@Model.Script.FileName)) 
    {
        <script src="@Url.Content( @Model.Script.FileName)"></script>
    }
    else
    {
        <script src="@Url.Content("~/resources/js/default.js")"></script>
    }

    @if (@Model.Script.Scripts != null)
    {
        foreach (var script in @Model.Script.Scripts)
        {
            <script src="@Url.Content( script.FileName)"></script>
        }
    }

</head>
<body>
    
    @RenderPage("~/Views/Main/_ViewPort.cshtml")

    @* carregando os Google Analytcs caso exista*@
    @if (Model.GoogleAnalytics != null && String.IsNullOrWhiteSpace(Model.GoogleAnalytics.IDAcompanhamento))
    {
        if (String.IsNullOrWhiteSpace(Model.GoogleAnalytics.ExtraConfig))
        {
            Model.GoogleAnalytics.ExtraConfig = "'auto'";
        }
        
        <script>
            
            (function (i, s, o, g, r, a, m) {
                i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
                    (i[r].q = i[r].q || []).push(arguments)
                }, i[r].l = 1 * new Date(); a = s.createElement(o),
                m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
            })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

            ga('create', '@Model.GoogleAnalytics.IDAcompanhamento', @Model.GoogleAnalytics.ExtraConfig);
            ga('send', 'pageview');
        </script>
    }
</body>
</html>
